package com.lyf.scm.plan.domain.repository;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyf.scm.plan.api.dto.*;
import com.lyf.scm.plan.domain.convertor.*;
import com.lyf.scm.plan.insfrastructure.db.dataobject.OperationLogRecordDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanOtherAccuracyDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanOtherDO;
import com.lyf.scm.plan.insfrastructure.db.dataobject.SalesPlanSelectDO;
import com.lyf.scm.plan.insfrastructure.db.mapper.SalesPlanOtherMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * description:
 * 其他渠道计划
 *
 * @author: huangtao
 * @data: 2020/7/31
 */
@Service
public class SalesPlanOtherRespository {

    @Resource
    private SalesPlanOtherConvertor salesPlanOtherConvertor;
    @Resource
    private SalesPlanOtherSelectConvertor salesPlanOtherSelectConvertor;
    @Resource
    private SalesPlanOtherMapper salesPlanOtherMapper;
    @Resource
    private SalesPlanSelectConvertor salesPlanSelectConvertor;
    @Resource
    private SalesPlanOtherAccuracySelectConvertor salesPlanOtherAccuracySelectConvertor;
    @Resource
    private SalesPlanOtherAccuracyConvertor salesPlanOtherAccuracyConvertor;

    public PageInfo<Map<String, String>> listWeekBySelective(SalesPlanOtherDTO slaesPlanOther) {
         PageHelper.startPage(slaesPlanOther.getPageNum(),slaesPlanOther.getPageSize());
        return new PageInfo(salesPlanOtherMapper.listWeekBySelective(salesPlanOtherSelectConvertor.dtoToDO(slaesPlanOther)));
        /*PageHelper.startPage(slaesPlanOther.getPageNum(), slaesPlanOther.getPageSize());
        SalesPlanSelectDO salesPlanSelectDO = salesPlanOtherSelectConvertor.dtoToDO(slaesPlanOther);
        return new PageInfo(salesPlanOtherMapper.listWeekBySelective(salesPlanSelectDO));*/
    }

    public List<Map<String, String>> listWeekBySelectiveAll(SalesPlanOtherDTO slaesPlanOther) {
        return salesPlanOtherMapper.listWeekBySelective(salesPlanOtherSelectConvertor.dtoToDO(slaesPlanOther));
    }

    public PageInfo<SalesPlanOtherAccuracyDO> listWeekBySelectiveAccuracy(SalesPlanOtherAccuracyDTO slaesPlanOtherAccuracy) {
        PageHelper.startPage(slaesPlanOtherAccuracy.getPageNum(), slaesPlanOtherAccuracy.getPageSize());
        SalesPlanSelectDO salesPlanSelectDO = salesPlanOtherAccuracySelectConvertor.dtoToDO(slaesPlanOtherAccuracy);
        return new PageInfo(salesPlanOtherMapper.listWeekBySelectiveAccuracy(salesPlanSelectDO));
    }

    public List<SalesPlanOtherDTO> listAllByCondition(SalesPlanOtherDTO slaesPlanOther) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listAllByCondition(salesPlanOtherSelectConvertor.dtoToDO(slaesPlanOther)));
    }

    public List<SalesPlanOtherAccuracyDTO> listAllByConditionAccuracy(SalesPlanOtherAccuracyDTO salesPlanOtherAccuracyDTO) {
        return salesPlanOtherAccuracyConvertor.doToDTO(salesPlanOtherMapper.listAllByConditionAccuracy(salesPlanOtherAccuracySelectConvertor.dtoToDO(salesPlanOtherAccuracyDTO)));
    }

    public List<SalesPlanOtherDTO> listSalesAndTarget(SalesPlanOtherDO salesPlanOtherDO) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listSalesAndTarget(salesPlanOtherDO));
    }

    public List<SalesPlanOtherAccuracyDTO> listSalesAndTargetAccuracy(SalesPlanOtherAccuracyDO salesPlanOtherAccuracyDO) {
        return salesPlanOtherAccuracyConvertor.doToDTO(salesPlanOtherMapper.listSalesAndTargetAccuracy(salesPlanOtherAccuracyDO));
    }

    public List<SalesPlanOtherDTO> listAllByCycles(SalesPlanOtherDTO slaesPlanOther) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listAllByCycles(salesPlanOtherSelectConvertor.dtoToDO(slaesPlanOther)));
    }

    public List<SalesPlanOtherAccuracyDTO> listAllByCyclesAccuracy(SalesPlanOtherAccuracyDTO salesPlanOtherAccuracy) {
        return salesPlanOtherAccuracyConvertor.doToDTO(salesPlanOtherMapper.listAllByCyclesAccuracy(salesPlanOtherAccuracySelectConvertor.dtoToDO(salesPlanOtherAccuracy)));
    }

    public List<SalesPlanOtherDTO> getListById(List<Long> ids) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getListById(ids));
    }


    public Integer addPlanOtherData(List<SalesPlanOtherDTO> dtoList) {
        return salesPlanOtherMapper.addPlanOtherData(salesPlanOtherConvertor.dtoToDO(dtoList));
    }


    public Integer updatePlanOtherType(List<SalesPlanOtherDTO> dtoList) {
        return salesPlanOtherMapper.updatePlanOtherType(salesPlanOtherConvertor.dtoToDO(dtoList));
    }


    public Integer updateConfirm(List<SalesPlanOtherDTO> dtoList) {
        return salesPlanOtherMapper.updateConfirm(salesPlanOtherConvertor.dtoToDO(dtoList));
    }


    public List<SalesPlanOtherDTO> getListByNumbers(List<String> nums) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getListByNumbers(nums));
    }

    public List<SalesPlanOtherDTO> listPlanOther(DemandPlanDTO demandPlan) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listPlanOther(salesPlanSelectConvertor.demandPlanToOtherDo(demandPlan)));
    }

    public List<SalesPlanOtherDTO> getRepeatPro(SalesPlanOtherDTO dtos) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getRepeatPro(salesPlanOtherConvertor.dtoToDO(dtos)));
    }

    public List<SalesPlanOtherDTO> getRepeatCity(SalesPlanOtherDTO dtos) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getRepeatCity(salesPlanOtherConvertor.dtoToDO(dtos)));
    }

    public List<SalesPlanOtherDTO> getRepeatStore(SalesPlanOtherDTO dtos) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getRepeatStore(salesPlanOtherConvertor.dtoToDO(dtos)));
    }

    public Integer updateAll(List<SalesPlanOtherDTO> dtos) {
        return salesPlanOtherMapper.updateAll(salesPlanOtherConvertor.dtoToDO(dtos));
    }

    public Integer updateConfirmStatus() {
        return salesPlanOtherMapper.updateConfirmStatus();
    }

    public Integer updateCancelStatus() {
        return salesPlanOtherMapper.updateCancelStatus();
    }


    public List<SalesPlanOtherDTO> listSalesAndTargetDifferent(SalesPlanOtherDO salesPlanOtherDO) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listSalesAndTargetDifferent(salesPlanOtherDO));
    }

    public List<SalesPlanOtherDTO> listAllByDifferentCycles(SalesPlanOtherDTO salesPlanOtherDTO) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listAllByDifferentCycles(salesPlanOtherDTO));
    }

    public List<SalesPlanOtherDTO> listAllByConditionDifferent(SalesPlanOtherDTO salesPlanOtherDTO) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listAllByConditionDifferent(salesPlanOtherSelectConvertor.dtoToDO(salesPlanOtherDTO)));
    }

    public List<SalesPlanOtherDTO> listBySalesOtherPlan() {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.listBySalesOtherPlan());
    }

    public void updatePushStatus(String store, Date arrivalDate, Integer statusType, Integer presaleType, String msg) {
        salesPlanOtherMapper.updatePushStatus(store, arrivalDate, statusType, presaleType, msg);
    }

    public void delete(String opSign) {
        salesPlanOtherMapper.delete(opSign);
    }

    public void deleteByOpSign(String opSign) {
        salesPlanOtherMapper.deleteByOpSign(opSign);
    }

    public List<SalesPlanOtherDTO> getLastWeekByType(Date startTime, Date endTime, List<String> types) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getLastWeekByType(startTime, endTime, types));
    }

    public void updateLastDate(List<SalesPlanOtherDTO> saleLists) {
        salesPlanOtherMapper.updateLastDate(salesPlanOtherConvertor.dtoToDO(saleLists));
    }

    public List<SalesPlanOtherDTO> getLastPlanData(SalesPlanOtherDTO salesPlanOtherDTO) {
        return salesPlanOtherConvertor.doToDTO(salesPlanOtherMapper.getLastPlanData(salesPlanOtherConvertor.dtoToDO(salesPlanOtherDTO)));
    }
}
